# -*- coding:utf-8 -*-

"""App start."""

import logging
import asyncio


from aiohttp import web

logging.basicConfig(level=logging.INFO)


def index(request):
    """Print a sentence on web page."""
    return web.Response(body=b'<h1>Awesome</h1>', headers={'content-type': 'text/\
    html'})


@asyncio.coroutine
def init(loop):
    """Create server."""
    app = web.Application(loop=loop)
    app.router.add_route('GET', '/', index)

    srv = yield from loop.create_server(app.make_handler(), '127.0.0.1', '\
    9000')
    logging.info('server start at http://127.0.0.1:9000')
    return srv


loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()
